#pragma once
#include"../CGI.h"
#include"GLLayer.h"
namespace BattleFire {
	class OpenGLCGI : public CGI{
	public:
		bool Initialize(HDC inHDC,int inViewWidth,int inViewHeight);
		RenderResource* CreateVertexBuffer(BattleFireAny* inLBufferData, int inPerVertexDataSizeInBytes, int inCountInBytes,BufferUsage inBufferUsage){ return nullptr;}
		RenderResource* CreateIndexBuffer(BattleFireAny* inLBufferData, int inPerElementSizeInBytes, int inCountInBytes, BufferUsage inBufferUsage){ return nullptr;}
		RenderResource* CreateShader(ShaderStage shaderStage, const char* shaderUserPath, const char* shaderSourceCode,int shaderCodeLen,bool shared=false){ return nullptr;}
		RenderResource* CreateShaderPipeline(LShaderPipeline* shaderPipeline){ return nullptr;}
	public:
		static PFNGLDISCARDFRAMEBUFFEREXT DiscardFramebuffer;
		static PFNGLDISPATCHCOMPUTE DispatchCompute;
		static PFNPUSHGROUPMARKER PushGroupMarker;
		static PFNPOPGROUPMARKER PopGroupMarker;
		static PFNINSERTEVENTMARKER InsertEventMarker;
	};
	struct MarkerEvent {
		MarkerEvent(const char* text) {
			if (OpenGLCGI::PushGroupMarker) {
				OpenGLCGI::PushGroupMarker(strlen(text), text);
			}
		}
		~MarkerEvent() {
			if (OpenGLCGI::PopGroupMarker) {
				OpenGLCGI::PopGroupMarker();
			}
		}
	};
	struct FormatedMarkerEvent {
		FormatedMarkerEvent(const char* format, ...) {
			if (OpenGLCGI::PushGroupMarker) {
				if (strlen(format) == 0)
					return;
				char szBuffer[256];
				memset(szBuffer, 0, 256);
				va_list	l_va;
				va_start(l_va, format);
				vsnprintf(szBuffer, sizeof(szBuffer), format, l_va);
				va_end(l_va);
				OpenGLCGI::PushGroupMarker(strlen(szBuffer), szBuffer);
			}
		}
		~FormatedMarkerEvent() {
			if (OpenGLCGI::PopGroupMarker) {
				OpenGLCGI::PopGroupMarker();
			}
		}
	};
#define SCOPED_EVENT(Message) BattleFire::MarkerEvent marker##__LINE__(#Message)
#define RENDER_EVENT(Message) do{ if(OpenGLCGI::InsertEventMarker)OpenGLCGI::InsertEventMarker(strlen(#Message),#Message); }while(0)
#define SCOPED_FORMATED_EVENT(f,...) BattleFire::FormatedMarkerEvent marker##__LINE__(f,##__VA_ARGS__)
}